package com.huawei.esdk.tp.device.smc.v100r002c01;

import com.huawei.esdk.platform.common.SDKResult;
import com.huawei.esdk.platform.common.exception.SDKException;
import com.huawei.esdk.platform.common.utils.ApplicationContextUtil;
import com.huawei.esdk.platform.commu.itf.ICXFSOAPProtocolAdapter;
import com.huawei.esdk.platform.exception.ProtocolAdapterException;
import com.huawei.esdk.tp.device.smc.ConferenceManagerCapabilityImpl;
import com.huawei.esdk.tp.device.smc.v100r002c01.convert.TPSMC20V1R2C01ConfMgrConvert;
import com.huawei.esdk.tp.domain.model.ScheduleConference;
import com.huawei.esdk.tp.southcommu.cxf.gen.v100r002c01.ScheduleConf;
import com.huawei.esdk.tp.southcommu.cxf.gen.v100r002c01.ScheduleConfResponse;
import com.huawei.esdk.tp.southcommu.cxf.gen.v100r002c01.SmcExternal2Soap;

public class SMC20V1R2C01ConferenceManagerCapabilityImpl extends
        ConferenceManagerCapabilityImpl implements
        SMC20V1R2C01IConferenceManagerCapability
{
    private TPSMC20V1R2C01ConfMgrConvert tpConfMgrConvert = ApplicationContextUtil
    .getBean("tpSMC20V1R2C01ConfMgrConvertService");

    /** * @param cxfSoapProtocolAdapter */
    public SMC20V1R2C01ConferenceManagerCapabilityImpl(
            ICXFSOAPProtocolAdapter cxfSOAPProtocolAdapter)
    {
        super(cxfSOAPProtocolAdapter);
    }

    protected String getSouthItfName()
    {
        return SmcExternal2Soap.class.getName();
    }

    @Override
    public SDKResult<ScheduleConference> scheduleConference(
            ScheduleConference conf)
    {

        SDKResult<ScheduleConference> result = new SDKResult<ScheduleConference>();
        ScheduleConfResponse responseSouth = null;
        try
        {
            ScheduleConf resMsg = tpConfMgrConvert
                .scheduleConfModel2soap(conf);
            
            responseSouth = (ScheduleConfResponse) sendProtocolMessage(
                    resMsg,getSouthItfName(), "scheduleConf");
            result = tpConfMgrConvert
                    .scheduleConfSoap2model(responseSouth);
        }
        catch (ProtocolAdapterException e)
        {
            result.setErrCode(e.getErrorCode());
            return result;
        }
        catch(SDKException e)
        {
            result.setErrCode(e.getSdkErrCode());
            return result;
        }

        return result;
    }
}
